package cn.changeforyou.web.blog.service.impl;

import cn.changeforyou.web.blog.po.Comment;
import cn.changeforyou.web.blog.service.CommentService;
import java.util.List;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;

/**
 * @author zhyu
 * @date 2021/3/9 15:11
 */
@IocBean
public class CommentServiceImpl implements CommentService {

    @Inject
    private Dao dao;

    @Override
    public Comment getById(int id) {
        List<Comment> comments = dao.query(Comment.class, Cnd.where("id", "=", id));
        if(comments.isEmpty()) {
            return null;
        }
        return comments.get(0);
    }
}
